package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter@Getter
public class TravelCommend extends BaseDomain{
public static final int TYPE_WEEK=1;
public static final int TYPE_MONTH=2;
public static final int TYPE_COMMEND=3;

    private Travel travel;

    private String title;

    private String subTitle;

    private String coverUrl;
    @JsonFormat(pattern ="yyyy-MM-dd" , timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type;


    public String getTypeName(){
        String typeName="";
        if (type==TYPE_WEEK){
            typeName="周推荐";
        }else if (type==TYPE_MONTH){
            typeName="月推荐";
        }else if (type==TYPE_COMMEND){
            typeName="攻略推荐";
        }

        return typeName;
    }


    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        String formatDate = DateUtil.formatDate(schedule);
        map.put("travelId",travel.id);
        map.put("id",getId());
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule",formatDate);
        map.put("type",type);


        return JSONUtil.toJSONString(map);
    }



}